﻿Public Class Rocupacion

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Eocupacion)
        Dim ocupacions As List(Of Eocupacion) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                ocupacions = Docupacion.SeleccionarTodo(descEmpresa)
                If ocupacions Is Nothing Then ocupacions = New List(Of Eocupacion)
                If DisplaySelect Then ocupacions.Insert(0, New Eocupacion("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return ocupacions
    End Function
    Public Shared Function SeleccionarXEstado(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Eocupacion)
        Dim ocupacions As List(Of Eocupacion) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                ocupacions = Docupacion.SeleccionarXEstado(descEmpresa)
                If ocupacions Is Nothing Then ocupacions = New List(Of Eocupacion)
                If DisplaySelect Then ocupacions.Insert(0, New Eocupacion("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return ocupacions
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pOcupacion As Eocupacion) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Docupacion.Añadir(descEmpresa, pOcupacion)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pOcupacion As Eocupacion) As Boolean
        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                Docupacion.Editar(descEmpresa, pOcupacion)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pOcupacion As Eocupacion) As Boolean
        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                Docupacion.Eliminar(descEmpresa, pOcupacion)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
    End Function

End Class
